package com.ruoyi.web.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.admin.domain.TdmCmcWenXian;
import com.ruoyi.web.admin.service.ITdmCmcWenXianService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * CMC文献分类Controller
 * 
 * @author ly
 * @date 2022-03-10
 */
@RestController
@RequestMapping("/admin/TdmCmcWenXian")
public class TdmCmcWenXianController extends BaseController
{
    @Autowired
    private ITdmCmcWenXianService tdmCmcWenXianService;

    /**
     * 查询CMC文献分类列表
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmCmcWenXian:list')")
    @GetMapping("/list")
    public TableDataInfo list(TdmCmcWenXian tdmCmcWenXian)
    {
        startPage();
        List<TdmCmcWenXian> list = tdmCmcWenXianService.selectTdmCmcWenXianList(tdmCmcWenXian);
        return getDataTable(list);
    }

    /**
     * 导出CMC文献分类列表
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmCmcWenXian:export')")
    @Log(title = "CMC文献分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TdmCmcWenXian tdmCmcWenXian)
    {
        List<TdmCmcWenXian> list = tdmCmcWenXianService.selectTdmCmcWenXianList(tdmCmcWenXian);
        ExcelUtil<TdmCmcWenXian> util = new ExcelUtil<TdmCmcWenXian>(TdmCmcWenXian.class);
        util.exportExcel(response, list, "CMC文献分类数据");
    }

    /**
     * 获取CMC文献分类详细信息
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmCmcWenXian:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tdmCmcWenXianService.selectTdmCmcWenXianById(id));
    }

    /**
     * 新增CMC文献分类
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmCmcWenXian:add')")
    @Log(title = "CMC文献分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TdmCmcWenXian tdmCmcWenXian)
    {
        return toAjax(tdmCmcWenXianService.insertTdmCmcWenXian(tdmCmcWenXian));
    }

    /**
     * 修改CMC文献分类
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmCmcWenXian:edit')")
    @Log(title = "CMC文献分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TdmCmcWenXian tdmCmcWenXian)
    {
        return toAjax(tdmCmcWenXianService.updateTdmCmcWenXian(tdmCmcWenXian));
    }

    /**
     * 删除CMC文献分类
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmCmcWenXian:remove')")
    @Log(title = "CMC文献分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tdmCmcWenXianService.deleteTdmCmcWenXianByIds(ids));
    }
}
